import React, { useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import AppNavigator from './src/navigation/AppNavigator';
import { AuthManager } from './src/utils/api';
export default function App() {

  // 应用启动时初始化token缓存
  useEffect(() => {
    const initializeAuth = async () => {
      try {
        // 预加载token到缓存中
        await AuthManager.getToken();
      } catch (error) {
        console.error('Token缓存初始化失败:', error);
      }
    };

    initializeAuth();
  }, []);

  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <SafeAreaProvider>
        <AppNavigator />
        <StatusBar style="dark" backgroundColor="#ffffff" />
      </SafeAreaProvider>
    </GestureHandlerRootView>
  );
}